# coding=utf-8
"""
    CSDN_Python闯关特训营
    第二周闯关作业_赵文川
    本周共计3个作业：
    作业二： 请设计一个装饰器，它可以作用于任何函数上，打印函数执行时间：
"""
import time


def computer_runtime(func):
    def weapper():
        start = time.time()
        func()
        end = time.time()
        func()
        print('%s执行了%f 秒' % (func.__name__, end - start))

    return weapper


@computer_runtime
def run():
    time.sleep(1)
    l = [x ** 2 for x in range(100000)]


run()
# import time
# def metric(fn):
#     start_time = time.time()
#     fn()
#     end_time = time.time()
#     fn()
#     print('耗时：{:.4f}s'.format(end_time - start_time))
#     return fn
# @metric
# def run():
#     time.sleep(1)
#     l = [x ** 2 for x in range(100000)]
#
#
# run()